<?php
	require_once('includes.php');
	Session::start();
	
	//This function is used in for resetting password
	
	//Reset password
	if (isset($_POST['reset'])) {
		$username = $_POST['username'];
		$email = $_POST['email'];
		//Check if the username and e-mail are matching
		if (User::checkUsernameAndEmail($username, $email)) {
			//Reset the password
			User::resetPassword($username, $email);
			$message[] = 'MSG_PASSWORD_RESET';
		} else {
			$message[] = 'ERROR_EMAIL_WRONG';
		}	
		$_SESSION['message'] = $message;
		header('Location: ' . DIR . '/reset.php');
	}
?>